/* eslint-disable prettier/prettier */
// src/articles/articles.controller.ts
import {
  Body,
  Controller,
  Get,
  Param,
  Post,
  Query,
} from '@nestjs/common';
import { KnowledgeService } from './knowledge.service';
import { Knowledge } from './schemas/knowledge.schemas';
import { CreateKnowledgeDto } from './dto/create-knowledge.dto';


@Controller('knowledge')
export class KnowledgeController {
  constructor(private readonly knowledgeService: KnowledgeService) { }

  // 根据id查找对应文章数据
  @Get(':id')
  async findOne(@Param('id') id: string) {
    return await this.knowledgeService.findOne(id);
  }

  // 分页获取数据
  @Get('')
  async getRolesByPage(
    @Query('pageNum') pageNum: number,
    @Query('likeFlag') likeFlag: number,
  ) {
    return await this.knowledgeService.findSearch(
      pageNum,
      likeFlag
    );
  }

  @Post()
  async create(@Body() createKnowledgeDto: CreateKnowledgeDto): Promise<Knowledge> {
    return this.knowledgeService.create(createKnowledgeDto);
  }

  // @Get()
  // async findAll(): Promise<Knowledge[]> {
  //   return this.knowledgeService.findAll();
  // }

  // 根据likeFlag获取数据
  // @Get(':flag')
  // async findByLikeFlag(@Param('flag') flag: number): Promise<Knowledge[]> {
  //   return await this.knowledgeService.findByLikeFlag(flag);
  // }

  // @Put(':id')
  // async update(
  //   @Param('id') id: string,
  //   @Body() updateKnowledgeDto: CreateKnowledgeDto,
  // ): Promise<Knowledge> {
  //   return this.knowledgeService.update(id, updateKnowledgeDto);
  // }

  // @Delete(':id')
  // async remove(@Param('id') id: string): Promise<Knowledge> {
  //   return this.knowledgeService.remove(id);
  // }
}